package com.zhaoxi.demo.demo2;

import com.zhaoxi.demo.demo2.config.ProConfig;
import com.zhaoxi.demo.demo2.pros1.PropertiesDemo1;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Date;

/**
 * @author zxiaoming
 * @Description:测试自定义属性文件的装配方式
 * @date 2021/2/2821:39
 */
public class TestConfigProperties {
    public static void main(String[] args) {
//        method1();
        System.out.println(new Date(2021, 03, 01));
        method2();
    }
    public static void method1(){
        ApplicationContext context = new ClassPathXmlApplicationContext("context-properties.xml");
        PropertiesDemo1 pd = context.getBean("pd", PropertiesDemo1.class);
        pd.printUserDetail();
    }
    public static void method2(){
        ApplicationContext context = new AnnotationConfigApplicationContext(ProConfig.class);
        PropertiesDemo1 pd = context.getBean("getPropertiesDemo1", PropertiesDemo1.class);
        pd.printUserDetail();
    }
}
